﻿@using System.Security.Claims
@model string

<div class="jumbotron">
    @if (User?.Identity is { IsAuthenticated: true })
    {
        <h1>Welcome, @User.Identity.Name</h1>

        <p>
            @foreach (var claim in ((ClaimsPrincipal) Context.User).Claims)
            {
                <div>@claim.Type: <b>@claim.Value</b></div>
            }
        </p>

        if (!string.IsNullOrEmpty(Model))
        {
            <h3>Message received from the resource controller: @Model</h3>
        }

        <form action="~/" method="post">
            @Html.AntiForgeryToken()

            <button class="btn btn-lg btn-warning" type="submit">Query the resource controller</button>
        </form>

        <form action="~/logout" method="post">
            @Html.AntiForgeryToken()

            <button class="btn btn-lg btn-danger" type="submit">Sign out</button>
        </form>
    }

    else
    {
        <h1>Welcome, anonymous</h1>
        @Html.ActionLink("Sign in using the local OIDC server", "Login", "Authentication",
            new { provider = "local" }, new { @class = "btn btn-lg btn-success" })
    }
</div>